//
//  UITableViewController.swift
//  YRProject
//
//  Created by 薛永伟 on 2019/9/26.
//  Copyright © 2019 XueYongWei. All rights reserved.
//

import UIKit

class YRUITableViewController: UITableViewController,StoryboardLoadable {

    var dataSource :[String] = [
        "TestYRPlayerSliderViewController",
        "YRRangeViewViewController",
        ]
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        tableView.register(UITableViewCell.self, forCellReuseIdentifier: "reuseIdentifier")
        
       
        YRLog(URL.Tianqin.path)
        YRLog(URL.Tianqin.Home.path)
    }


    override func numberOfSections(in tableView: UITableView) -> Int {
        
        return 1
    }

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        
        return dataSource.count
    }

    
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        
        let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath)
        
        let item = dataSource[indexPath.row]
        cell.textLabel?.text = item
        return cell
    }
    
    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        
        
        let item = "YRProject.\(dataSource[indexPath.row])"
        
        if let clz = NSClassFromString(item) as? TestYRPlayerSliderViewController.Type{
            
            let vc = clz.loadFormStb(stb: UIStoryboard.init(name: "UI", bundle: nil))
            navigationController?.pushViewController(vc, animated: true)
        }
        else if let vcClz = NSClassFromString(item) as? UIViewController.Type {
            let vc = vcClz.init()
            navigationController?.pushViewController(vc, animated: true)
        }
        
        
//        let vc = dataSource[indexPath.row]
        
        
    }
    


}
